<template>
  <div class="container">
    <Divider dashed class="divider" />
    <Tabs name="tab1" @on-click="tabClick">
      <!-- <TabPane label="设定基本信息" name="0" :index="0">
        <base-info :base-type="baseType" @result="baseInfoAction"></base-info>
      </TabPane> -->
      <TabPane label="设定基本信息" name="0" :index="0">
        <base-info></base-info>
      </TabPane>
      <TabPane
        v-if="baseInfoId !== ''"
        label="设定流程节点"
        name="1"
        tab="tab1"
        :index="1"
      >
        <flow-setting
          :base-info-id="baseInfoId"
          @flowNodeData="setFlowDataAction"
        ></flow-setting>
      </TabPane>
      <template v-if="baseInfoId !== ''">
        <TabPane
          :label="item.label"
          :name="item.value"
          tab="tab1"
          v-for="(item, key) in tabList"
          :key="item.value"
          :index="key + 3"
        >
          <power-setting
            :base-info-id="baseInfoId"
            :tab-name="tabName"
            v-if="item.value == 10"
            :options="flowDataList"
          ></power-setting>
          <yaojian-setting
            :base-info-id="baseInfoId"
            :tab-name="tabName"
            v-if="item.value == 11"
            :options="flowDataList"
            @result="resultAction"
          ></yaojian-setting>
          <where-setting
            :base-info-id="baseInfoId"
            :tab-name="tabName"
            v-if="item.value == 12"
            :options="flowDataList"
            @result="resultAction"
          ></where-setting>
          <rule-setting
            :base-info-id="baseInfoId"
            :tab-name="tabName"
            v-if="item.value == 13"
            :options="flowDataList"
            @result="resultAction"
          ></rule-setting>
          <time-setting
            :base-info-id="baseInfoId"
            :tab-name="tabName"
            v-if="item.value == 14"
            :options="flowDataList"
            @result="resultAction"
          ></time-setting>
          <data-compare-setting
            :base-info-id="baseInfoId"
            :tab-name="tabName"
            v-if="item.value == 15"
            :options="flowDataList"
            @result="resultAction"
          ></data-compare-setting>
          <loop-setting
            :base-info-id="baseInfoId"
            :tab-name="tabName"
            v-if="item.value == 16"
            :options="flowDataList"
            @result="resultAction"
          ></loop-setting>
          <warning-setting
            :base-info-id="baseInfoId"
            :tab-name="tabName"
            v-if="item.value == 19"
            :options="flowDataList"
            @result="resultAction"
          ></warning-setting>
          <node-setting
            :base-info-id="baseInfoId"
            :tab-name="tabName"
            v-if="item.value == 18"
            :options="flowDataList"
            @result="resultAction"
          ></node-setting>
          <problem-setting
            :base-info-id="baseInfoId"
            :tab-name="tabName"
            v-if="item.value == 20"
            :options="flowDataList"
            @result="resultAction"
          ></problem-setting>
          <evaluate-setting
            :base-info-id="baseInfoId"
            :tab-name="tabName"
            v-if="item.value == 17"
            :options="flowDataList"
            @result="resultAction"
          ></evaluate-setting>
        </TabPane>
      </template>
      -->
    </Tabs>
  </div>
</template>

<script>
// import BaseInfo from '../CreateMoney'
import BaseInfo from '../index.vue'
import FlowSetting from '../CreateMoney/components/flow-setting'
import PowerSetting from '../CreateMoney/components/power-setting'
import YaojianSetting from '../CreateMoney/components/yaojian-setting'
import WhereSetting from '../CreateMoney/components/where-setting'
import RuleSetting from '../CreateMoney/components/rule-setting'
import TimeSetting from '../CreateMoney/components/time-setting'
import DataCompareSetting from '../CreateMoney/components/data-compare-setting'
import LoopSetting from '../CreateMoney/components/loop-setting'
import WarningSetting from '../CreateMoney/components/warning-setting'
import NodeSetting from '../CreateMoney/components/node-setting'
import ProblemSetting from '../CreateMoney/components/problem-setting'
import EvaluateSetting from '../CreateMoney/components/evaluate-setting'

export default {
  name: 'index',
  components: {
    EvaluateSetting,
    ProblemSetting,
    NodeSetting,
    WarningSetting,
    LoopSetting,
    DataCompareSetting,
    TimeSetting,
    RuleSetting,
    WhereSetting,
    YaojianSetting,
    PowerSetting,
    FlowSetting,
    BaseInfo
  },
  data () {
    return {
      formItem: {},
      tabList: [
        { label: '设定要件', value: '11' },
        { label: '设定条件', value: '12' },
        { label: '设定规则', value: '13' },
        { label: '设定权限', value: '10' },
        { label: '设定时限', value: '14' },
        { label: '设定数据对比', value: '15' },
        { label: '设定轮巡周期', value: '16' },
        { label: '设定公示评价', value: '17' },
        { label: '设定监督节点', value: '18' },
        { label: '设定预警报警', value: '19' },
        { label: '设定问题管控', value: '20' }
      ],
      flowDataList: [],
      baseInfoId: '',
      tabName: '',
      baseType: ''
    }
  },
  methods: {
    tabClick (name) {
      // console.log('=====', name)
      this.tabName = name
    },
    setFlowDataAction (data) {
      data.map((item) => {
        item.YaoJianList = []
        item.whereList = []
        item.ruleList = []
        item.timeList = []
        item.compareList = []
        item.loopList = []
        item.warningList = []
        item.nodeList = []
        item.problemList = []
        item.evaluateList = []
        item.powerList = []
        item.gov_base_id = this.baseInfoId
        return item
      })
      this.flowDataList = data
    },
    resultAction (data) {
      this.flowDataList = data
    },
    baseInfoAction (data) {
      // console.log('插入之后返回的id：', data)
      this.baseInfoId = data
    }
  },
  mounted () {
    // if (this.$route.query.type) {
    //   this.baseType = this.$route.query.type.toString()
    //   // console.log(this.baseType, 'baseType')
    // }
    if (this.$route.query.vtype) {
      this.vtype = this.$route.query.vtype
      // console.log(this.vtype, "vtype");
    }
    this.baseInfoId = this.$route.query.id
      ? this.$route.query.id
      : this.baseInfoId
  }
}
</script>

<style scoped>
.container {
  margin-bottom: 50px;
}
</style>
